<template>
  <div class="content">
    <h1>请您认真填写以下信息，以供医生参考：</h1>
    <el-form :model="user" label-width="120px">
      <el-form-item label="姓名">
        <el-input v-model="user.name"></el-input>
      </el-form-item>
      <el-form-item label="性别">
        <el-radio-group v-model="user.gender">
          <el-radio label="男">男</el-radio>
          <el-radio label="女">女</el-radio>
        </el-radio-group>
      </el-form-item>
      <el-form-item label="年龄">
        <el-input v-model="user.age"></el-input>
      </el-form-item>
      <el-form-item label="身高">
        <el-input v-model="user.height"></el-input>
      </el-form-item>
      <el-form-item label="体重">
        <el-input v-model="user.weight"></el-input>
      </el-form-item>
      <el-form-item label="病情描述">
        <el-input type="textarea" v-model="user.description"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="submit">确定</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<style scoped>
  .content {
    margin: 0 auto;
    width: 760px;
    height: 900px;
  }
</style>

<script setup>
  import { ref, onMounted } from "vue"
  import axios from "axios"
  import { useRoute, useRouter } from "vue-router"

  const route = useRoute()
  const router = useRouter()

  let doctor = route.query.id

  let user = ref({})

  const submit=()=>{
    axios.post(`http://127.0.0.1:8000/orders/orders/`, {doctor: doctor, detail: user.value.description}, {
      headers: {
        Authorization: 'Bearer ' + localStorage.getItem('access_token')
    }})
    .then(res=>{
      console.log(res)
      router.push("/update_file")
    })
  }

</script>